import axios from 'axios'
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import useCityStore from './cityStore'
const cityStore = useCityStore()

const useCinemaStore = defineStore('cinema', () => {
    const cinemaList = ref([])
    const getCinemaList = async () => {
        var res = await axios({
            url: `https://m.maizuo.com/gateway?cityId=${cityStore.cityId}&ticketFlag=1&k=4160775`,
            headers: {
                'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.1","e":"17089542072373175589470209","bc":"110100"}',
                'X-Host': 'mall.film-ticket.cinema.list',
            }
        })
        cinemaList.value = res.data.data.cinemas
    }
    const filterCinemaList = computed(() => (type) => {
        return cinemaList.value.filter(item => item.eTicketFlag === type)
    })
    const clearCinemaList = () => {
        cinemaList.value = []
    }



    return {
        cinemaList,
        getCinemaList,
        filterCinemaList,
        clearCinemaList,
    }
})
export default useCinemaStore